<?php

namespace App\Library;

use App\Models\IndustryCommentTag;

/**
 * 处理评价标签（商铺或团购）
 */
class HandleCommentTag
{
    public static function entry($tags)
    {
        if (!is_array($tags)) {
            return false;
        }
        $tags  = implode(',', $tags);
        $tags  = explode(',', $tags);
        $tags  = array_count_values($tags); //统计重复元素出现个数
        $array = [];
        foreach ($tags as $kk => $v) {
            $array[$kk]['tag_name'] = IndustryCommentTag::where('id', $kk)->value('name');
            $array[$kk]['count']    = $v;
        }

        return $array;
    }
}
